﻿using Common.Contract;
using Common.Contract.Customer;
using Common.Contract.Customer.Record;
using Common.Contract.Customer.Request;
using Common.Contract.Customer.Request.CustomerManager;
using Common.Contract.Customer.Request.PortfolioManagement;
using Common.Contract.Customer.Request.ReduceFee;
using Common.Contract.Customer.Response;
using Common.Contract.Customer.Response.CustomerManager;
using Common.Contract.Customer.Response.PortfolioManagement;
using Common.Contract.Customer.Response.ReduceFee;
using Customer.Core.ServiceCommand;
using Customer.Core.ServiceCommand.CustomerManager;
using Customer.Core.ServiceCommand.PortfolioManagement;
using Customer.Core.ServiceCommand.ReduceFee;
using Customer.Service.Core;
using System;

namespace Customer.Service
{
    public class CustomerService : ServiceBase, ICustomer
    {
        public RetrieveCustomerResponse RetrieveCustomer(RetrieveCustomerRequest request)
        {
            return new RetrieveCustomerServiceCommand(Provider).Execute(request);
        }
        public RetrieveListBranchResponse RetrieveListBranch(RetrieveListBranchRequest request)
        {
            return new RetrieveListBranchServiceCommand(Provider).Execute(request);
        }

        public RetrieveCustomerSubSegmentResponse RetrieveCustomerSubSegment(RetrieveCustomerSubSegmentRequest request)
        {
            return new RetrieveCustomerSubSegmentServiceCommand(Provider).Execute(request);
        }
        public CountCustSegmentResponse CountCustSegment(RetrieveCustomerSubSegmentRequest request)
        {
            CountCustSegmentResponse response = new CountCustSegmentResponse { IsSuccess = true, ErrorMessage = "" };
            try
            {
                if (request == null || request.Header == null || request.Header.ApplicationKey == null)
                {
                    response.ErrorMessage = "Invalidate the request header";
                    response.IsSuccess = false;
                    return response;
                }
                if (request.CurrentUser == null)
                {
                    response.ErrorMessage = "MSBO Dao must be set";
                    response.IsSuccess = false;
                    return response;
                }
                string errorMessage = string.Empty;
                CountCustSegmentRecord record = new CountCustSegmentRecord();
                record = Provider.Customers.CountCustSubSegment(request.CurrentUser);
                response.Record = record;
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
                response.ErrorMessage = string.Format("Can not found user with ApplicationKey={0} in UserName={1}", request.Header.ApplicationKey, request.CurrentUser.UserName);
                response.IsSuccess = false;
                return response;
            }
            return response;
        }
        public RetrieveCustomerPriorityResponse RetrieveCustomerPriority(RetrieveCustomerPriorityRequest request)
        {
            return new RetrieveCustomerPriorityServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerResponse RetrieveTotalCustomer(RetrieveCustomerRequest request)
        {
            return new RetrieveTotalCustomerServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerCelebrationResponse RetrieveCustomerCelebration(RetrieveCustomerCelebrationRequest request)
        {
            return new RetrieveCustomerCelebrationServiceCommand(Provider).Execute(request);
        }
        public RetrieveListProductResponse RetrieveListProduct(RetrieveListProductRequest request)
        {
            return new RetrieveListProductServiceCommand(Provider).Execute(request);
        }

        public RetrieveCustomerI2bDetailByCifResponse RetrieveCustomerI2bDetailByCif(RetrieveCustomerI2bDetailByCifRequest request)
        {
            return new RetrieveCustomerI2bDetailByCifServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerRepresentativeCelebrationResponse RetrieveCustomerRepresentativeCelebration(RetrieveCustomerRepresentativeCelebrationRequest request)
        {
            return new RetrieveCustomerRepresentativeCelebrationServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerFreedomResponse RetrieveCustomerFreedom(RetrieveCustomerFreedomRequest request)
        {
            return new RetrieveCustomerFreedomServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerInfoResponse RetrieveCustomerInfoByCif(RetrieveCustomerInfoRequest request)
        {
            return new RetrieveCustomerInfoByCifServiceCommand(Provider).Execute(request);
        }
        public RetrieveNewLendingInfoResponse RetrieveNewLendingInfoByCif(RetrieveNewLendingInfoRequest request)
        {
            return new RetrieveNewLendingInfoServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerCardDetailByCifResponse RetrieveCustomerCardDetailByCif(RetrieveCustomerCardDetailByCifRequest request)
        {
            return new RetrieveCustomerCardDetailByCifServiceCommand(Provider).Execute(request);
        }
        public RetrieveRelCusInfoResponse RetrieveRelCusInfoByCif(RetrieveRelCusInfoRequest request)
        {
            return new RetrieveRelCusInfoByCifServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerBadBankResponse RetrieveCustomerBadBank(RetrieveCustomerAlertRequest request)
        {
            return new RetrieveCustomerBadBankServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerAlertOverdueResponse RetrieveCustomerAlertOverdue(RetrieveCustomerAlertRequest request)
        {
            return new RetrieveCustomerAlertOverdueServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerAlertBadbankResponse RetrieveCustomerAlertBadBank(RetrieveCustomerAlertRequest request)
        {
            return new RetrieveCustomerAlertBadBankServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerLoanMatdtResponse RetrieveCustomerLoanMatdt(RetrieveCustomerAlertRequest request)
        {
            return new RetrieveCustomerLoanMatdtServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerAlertCasaResponse RetrieveCustomerAlertCasa(RetrieveCustomerAlertRequest request)
        {
            return new RetrieveCustomerAlertCasaServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerAlertLcResponse RetrieveCustomerAlertLc(RetrieveCustomerAlertRequest request)
        {
            return new RetrieveCustomerAlertLcServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerAlertBLResponse RetrieveCustomerAlertBL(RetrieveCustomerAlertRequest request)
        {
            return new RetrieveCustomerAlertBLServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerAlertInactiveResponse RetrieveCustomerAlertInactive(RetrieveCustomerAlertRequest request)
        {
            return new RetrieveCustomerAlertInactiveServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerAlertLimitResponse RetrieveCustomerAlertLimit(RetrieveCustomerAlertRequest request)
        {
            return new RetrieveCustomerAlertLimitServiceCommand(Provider).Execute(request);
        }
        public RetrieveTblAlertDepositMatdtResponse RetrieveTblAlertDepositMatdt(RetrieveCustomerAlertRequest request)
        {
            return new RetrieveTblAlertDepositMatdtServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerTop10Response RetrieveCustomerTop10(RetrieveCustomerTop10Request request)
        {
            return new RetrieveCustomerTop10ServiceCommand(Provider).Execute(request);
        }
        public RetrieveAccountPlanningResponse RetrieveAccountPlanning(RetrieveAccountPlanningRequest request)
        {
            return new RetrieveAccountPlanningServiceCommand(Provider).Execute(request);
        }
        public RetrieveAccountPlanningByCifResponse RetrieveAccountPlanningByCif(RetrieveAccountPlanningByCifRequest request)
        {
            return new RetrieveAccountPlanningByCifServiceCommand(Provider).Execute(request);
        }
        public RetrieveAccountPlanningDataViewResponse RetrieveAccountPlanningFinanceDataViewByTime(RetrieveAccountPlanningDataViewRequest request)
        {
            return new RetrieveAccountPlanningFinanceDataViewByTimeServiceCommand(Provider).Execute(request);
        }
        public RetrieveAccountPlanningDataViewResponse RetrieveAccountPlanningProductHoldingDataViewByTime(RetrieveAccountPlanningDataViewRequest request)
        {
            return new RetrieveAccountPlanningProductHoldingDataViewByTimeServiceCommand(Provider).Execute(request);
        }
        public RetrieveDataAccountPlanningByCifResponse RetrieveAccountPlanningFinanceByCif(RetrieveDataAccountPlanningByCifRequest request)
        {
            return new RetrieveAccountPlanningFinanceByCifServiceCommand(Provider).Execute(request);
        }
        public RetrieveDataAccountPlanningByCifResponse RetrieveAccountPlanningProductHoldingByCif(RetrieveDataAccountPlanningByCifRequest request)
        {
            return new RetrieveAccountPlanningProductHoldingServiceCommand(Provider).Execute(request);
        }
        public ResponseRecord UpdateAccountPlanning(UpdateAccountPlanningRequest request)
        {
            return new UpdateAccountPlanningServiceCommand(Provider).Execute(request);
        }
        public ResponseRecord UpdateAccountPlanningFinance(UpdateDataAccountPlanningRequest request)
        {
            return new UpdateAccountPlanningFinanceServiceCommand(Provider).Execute(request);
        }
        public ResponseRecord UpdateAccountPlanningProductHolding(UpdateDataAccountPlanningRequest request)
        {
            return new UpdateAccountPlanningProductHoldingServiceCommand(Provider).Execute(request);
        }
        public RetrieveAccountPlanningHistoryResponse RetrieveAccountPlanningHistoryByCif(RetrieveAccountPlanningHistoryRequest request)
        {
            return new RetrieveAccountPlanningHistoryByCifServiceCommand(Provider).Execute(request);
        }
        public RetrieveAccountPlanningHistoryResponse RetrieveAccountPlanningHistoryByCifType(RetrieveAccountPlanningHistoryRequest request)
        {
            return new RetrieveAccountPlanningHistoryByCifTypeServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerFeedbackResponse RetrieveCustomerFeedbackByDao(RetrieveCustomerFeedbackRequest request)
        {
            return new RetrieveCustomerFeedbackByDaoServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerFeedbackDetailByCifResponse RetrieveCustomerFeedbackDetailByCif(RetrieveCustomerFeedbackDetailByCifRequest request)
        {
            return new RetrieveCustomerFeedbackDetailByCifServiceCommand(Provider).Execute(request);
        }
        public RetrieveListCustomerResponse RetrieveListCustomer(RetrieveListCustomerRequest request)
        {
            return new RetrieveListcustomerServiceCommand(Provider).Execute(request);
        }
        public RetrieveCountCustomerAlertResponse RetriveCountCustomerAlert(RetriveCountCustomerAlertRequest request)
        {
            return new RetriveCountCustomerAlertServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerReduceInfoResponse RetrieveCustomerReduceInfoByCif(RetrieveCustomerReduceInfoRequest request)
        {
            return new RetrieveCustomerReduceInfoByCifServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerFinanceInfoByCifResponse RetrieveCustomerFinanceInfoByCif(RetrieveCustomerFinanceInfoByCifRequest request)
        {
            return new RetrieveCustomerFinanceInfoByCifServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerLimitInfoByCifResponse RetrieveCustomerLimitInfoByCif(RetrieveCustomerLimitInfoByCifRequest request)
        {
            return new RetrieveCustomerLimitInfoByCifServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerLowValueResponse RetrieveCustomerLowValue(RetrieveCustomerLowValueRequest request)
        {
            return new RetrieveCustomerLowValueServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerAlertCardOverdueResponse RetrieveCustomerAlertCardOverdue(RetrieveCustomerAlertRequest request)
        {
            return new RetrieveCustomerAlertCardOverdueServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerAlertGeneralResponse RetrieveCustomerAlertGeneral(RetrieveCustomerAlertRequest request)
        {
            return new RetrieveCustomerAlertGeneralServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerNeedToUpdateResponse RetrieveCustomerNeedToUpdate(RetrieveCustomerNeedToUpdateRequest request)
        {
            return new RetrieveCustomerNeedToUpdateServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerNeedUpdateInfoRawResponse RetrieveCustomerNeedUpdateInfoRawByCif(RetrieveCustomerNeedUpdateInfoRawRequest request)
        {
            return new RetrieveCustomerNeedUpdateInfoRawByCifServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerNeedUpdateInfoRawResponse RetrieveCustomerNeedUpdateInfoRaw(RetrieveCustomerNeedUpdateInfoRawRequest request)
        {
            return new RetrieveCustomerNeedUpdateInfoRawServiceCommand(Provider).Execute(request);
        }
        public RetrieveCustomerLoanMatdtForExportResponse RetrieveCustomerLoanMatdtForExport(RetrieveCustomerAlertRequest request)
        {
            return new RetrieveCustomerLoanMatdtForExportServiceCommand(Provider).Execute(request);
        }
    }
}
